package com.scs.application.modules.dept.controller;

import com.scs.application.core.mvc.controller.CrudController;
import com.scs.application.modules.base.annotation.MatrCanPass;
import com.scs.application.modules.dept.entity.ApplyAuto;
import com.scs.application.modules.dept.service.PurchaseAutoService;
import com.scs.application.modules.sys.model.RestResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 */
@RestController
@RequestMapping("/dept/purchase_auto")
public class PurchaseAutoController extends CrudController<PurchaseAutoService, ApplyAuto>{


    /**
     * 转采购
     * 自动转采购：二级库专购品（响应后会跳转到采购订单的明细页面）=中心库采购需求（采购点击确认后没跳转到采购订单的明细页面）
     * @param applyAutos
     * @return
     */
    @PostMapping("toPurchase")
    @MatrCanPass(businessType = "purchase")
    public RestResult toPurchase(@RequestBody List<ApplyAuto> applyAutos) {
        return RestResult.ok("OK", service.toPurchase(applyAutos));
    }


    /**
     * 转需求
     *
     * @param applyAutos
     * @return
     */
    @PostMapping("toDemand")
    @MatrCanPass(businessType = "purchase")
    public RestResult toDemand(@RequestBody List<ApplyAuto> applyAutos) {
        return RestResult.ok("OK", service.toDemand(applyAutos));
    }

    /**
     * 填充开单数量
     * @param applyAutos
     * @return
     */
    @PostMapping("fillQty")
    public RestResult fillQty(@RequestBody List<ApplyAuto> applyAutos) {
        return RestResult.ok("操作成功",service.fillQty(applyAutos));
    }
}
